#ifndef _socket_sockethandler_h
#define _socket_sockethandler_h

#include <list>
using std::list;

#include <string>
using std::string;

#include "Socket.h"
#include "EventPoller.h"
#include "ObjectPool.h"
#include "Mutex.h"
#include "Task.h"

using namespace ddserver::utility;
using namespace ddserver::thread;

namespace ddserver
{
namespace socket
{

class SocketHandler
{
public:
    SocketHandler();
    ~SocketHandler();

public:
    void listen(const string& ip,int port);
    void attach(Socket* socket);
    void detach(Socket* socket);
    void modify(Socket* socket);
    void remove(Socket* socket);
    void handle(int max_connections, int wait_time,int servertype);

private:
    EventPoller * m_epoll;
    Socket * m_server;
    ObjectPool<Socket> m_sockpool;
    Mutex m_mutex;
};

}
}

#endif